package funnytrails;

import org.apache.wicket.Page;
import org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler;
import org.apache.wicket.core.request.handler.PageProvider;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.util.io.IClusterable;

public final class FrameTarget implements IClusterable
{
    private static final long serialVersionUID = 1L;

    /** the class of the bookmarkable page. */
    private Class<? extends Page> frameClass;

    /**
     * Construct.
     */
    public FrameTarget()
    {
    }

    /**
     * Construct.
     * 
     * @param <C>
     * 
     * @param frameClass
     */
    public <C extends Page> FrameTarget(Class<C> frameClass)
    {
        this.frameClass = frameClass;
    }

    /**
     * Gets frame class.
     * 
     * @return lefFrameClass
     */
    public Class<? extends Page> getFrameClass()
    {
        return frameClass;
    }

    /**
     * Sets frame class.
     * 
     * @param <C>
     * 
     * @param frameClass
     *            lefFrameClass
     */
    public <C extends Page> void setFrameClass(Class<C> frameClass)
    {
        this.frameClass = frameClass;
    }

    /**
     * @return URL to this frame class
     */
    public CharSequence getUrl()
    {
        return RequestCycle.get().urlFor(new BookmarkablePageRequestHandler(new PageProvider(frameClass)));
    }
}